/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unesp.rc.rafaelt.model.bean;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.sun.istack.NotNull;

/**
 * 
 * @author rafaelt
 */
@Entity
@Table(name = "student")
@XmlRootElement(name = "student")
/*@NamedQueries({
		@NamedQuery(name = "Student.findAll", query = "SELECT s FROM Student s"),
		@NamedQuery(name = "Student.findByIdStudent", query = "SELECT s FROM Student s WHERE s.idStudent = :idStudent"),
		@NamedQuery(name = "Student.findByFirstName", query = "SELECT s FROM Student s WHERE s.firstName = :firstName"),
		@NamedQuery(name = "Student.findByLastName", query = "SELECT s FROM Student s WHERE s.lastName = :lastName"),
		@NamedQuery(name = "Student.findByBirthday", query = "SELECT s FROM Student s WHERE s.birthday = :birthday") })*/
public class Student implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@NotNull
	@Column(name = "idStudent")
	private Long idStudent;
	
	@Basic(optional = false)
	@NotNull
	@Size(min = 1, max = 45)
	@Column(name = "firstName")
	private String firstName;
	
	@Basic(optional = false)
	@NotNull
	@Size(min = 1, max = 45)
	@Column(name = "lastName")
	private String lastName;
	
	@Basic(optional = false)
	@NotNull
	@Column(name = "birthday")
	@Temporal(TemporalType.DATE)
	private Date birthday;
	
//	@OneToMany(cascade = CascadeType.ALL, mappedBy = "student")
//	private Collection<Mark> markCollection;

	public Student() {
	}

	public Student(Long idStudent) {
		this.idStudent = idStudent;
	}

	public Student(Long idStudent, String firstName, String lastName,
			Date birthday) {
		this.idStudent = idStudent;
		this.firstName = firstName;
		this.lastName = lastName;
		this.birthday = birthday;
	}

	public Long getIdStudent() {
		return idStudent;
	}

	public void setIdStudent(Long idStudent) {
		this.idStudent = idStudent;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

//	@XmlTransient
//	public Collection<Mark> getMarkCollection() {
//		return markCollection;
//	}
//
//	public void setMarkCollection(Collection<Mark> markCollection) {
//		this.markCollection = markCollection;
//	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (idStudent != null ? idStudent.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof Student)) {
			return false;
		}
		Student other = (Student) object;
		if ((this.idStudent == null && other.idStudent != null)
				|| (this.idStudent != null && !this.idStudent
						.equals(other.idStudent))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "br.unesp.rc.model.bean.Student[ idStudent=" + idStudent + " ]";
	}

}
